package com.liangwj.springbootredis;
/**
 * <b>Description:</b> 学习spring的 代码 设计 <br/>
 * @author Lingwenjun
 * @date 2018/12/14-18:14
 * @version 1.0
 */
public class TestJavaBean {

    private Long id;
    private String userName;

    public TestJavaBean(Long id, String userName) {
        this.id = id;
        this.userName = userName;
    }

    public static TestJavaBean defaultTestJavaBean() {
        return new TestJavaBean(1L, "liangwenjun");
    }
    public Long getId() {
        return id;
    }

    public TestJavaBean setId(Long id) {
        this.id = id;
        return new TestJavaBean(id, "");
    }

    public String getUserName() {
        return userName;
    }

    public TestJavaBean setUserName(String userName) {
        this.userName = userName;
        return new TestJavaBean(0l, userName);
    }

    public TestJavaBean build() {
        return new TestJavaBean(this.id, this.userName);
    }
    public static void main(String[] args) {
        TestJavaBean test = TestJavaBean.defaultTestJavaBean()
                    .setId(2l)
                    .setUserName("liangasdasdas")
                    .build();
        System.out.println(test.getId() +  test.getUserName());
    }
}
